<?php


namespace app\admin\middleware;

use Closure;
use think\Response;

class Auth
{
    public function handle($request, Closure $next)
    {
        //前置中间件
        if(empty(session(config("admin.session_admin"))) && !preg_match("/login/",$request->pathinfo())){
            return redirect((string) url("login/index"));
        }
        $response = $next($request);
//        if(empty(session(config("admin.session_admin"))) && $request->controller() != "Login"){
//            return redirect((string) url("login/index"));
//        }
        return $response;
    }
    public function end(Response $response)
    {
    }
}